<template>
  <view id="app">
    <!-- 应用根容器 -->
  </view>
</template>

<script>
// 普通 JavaScript 版本用于 H5
let firstBackTime = 0
export default {
  name: 'App',
  onLaunch: function () {
    console.log('App Launch')
  },
  onShow: function () {
    console.log('App Show')
  },
  onHide: function () {
    console.log('App Hide')
  },
  // #ifdef APP-ANDROID
  onLastPageBackPress: function () {
    console.log('App LastPageBackPress')
    if (firstBackTime == 0) {
      uni.showToast({
        title: '再按一次退出应用',
        position: 'bottom',
      })
      firstBackTime = Date.now()
      setTimeout(() => {
        firstBackTime = 0
      }, 2000)
    } else if (Date.now() - firstBackTime < 2000) {
      firstBackTime = Date.now()
      uni.exit()
    }
  },
  // #endif
  onExit: function () {
    console.log('App Exit')
  },
}
</script>

<style>
/*每个页面公共css */
.uni-row {
  flex-direction: row;
}

.uni-column {
  flex-direction: column;
}

#app {
  width: 100%;
  height: 100%;
}
</style>